﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace VechicleRepairLab
{
	public class Car
	{
		public int Year { get; set; }
		public string Maker { get; set; }
		public string Model { get; set; }

		private void specTypesToolStripMenuItem_Click(object sender, EventArgs eventArgs)
		{
			DataTable cars = CreateTableWithClass();

			DataRow newAuto = cars.NewRow();
			newAuto["Vin"] = "1234567890ABCD";

			Car car = new Car { Maker = "GMC", Model = "H2", Year = 2009 };
			newAuto["CarObject"] = car;

			cars.Rows.Add(newAuto);

			Car newCar = (Car) cars.Rows[0]["CarObject"];
			//Form1.label
		}
		
		public DataTable CreateTableWithClass()
		{
			DataTable cars = new DataTable("Car");

			DataColumn vin = new DataColumn("vin");
			vin.DataType = typeof (string);
			vin.MaxLength = 23;
			vin.Unique = true;
			vin.AllowDBNull = false;
			vin.Caption = "VIN";

			cars.Columns.Add(vin);

			DataColumn dataColumn = new DataColumn("CarObject", typeof(Car));

			cars.Columns.Add(dataColumn);

			cars.PrimaryKey = new DataColumn[] { vin } ;

			return cars;
		}
	}
}
